package com.googlecode.smartbinding.framework.core;

import com.googlecode.smartbinding.framework.converter.Converter;
import com.googlecode.smartbinding.framework.validator.Validator;

/**
 * Data binding manager.<br/>
 * - performs databinding. <br/>
 * - utility methods for showing validation errors etc.
 *
 * @author Iulian Dumitru
 */
public interface DataBindingManager {


    /**
     * Perform databinding between a source and a target.<br/>
     * Please note that the 'target' class/members must be annotated.<br/>
     * See {@link com.googlecode.smartbinding.framework.core.Bindable}<br/>
     * See {@link com.googlecode.smartbinding.framework.core.Binding}<br/>
     * See {@link Validator}<br/>
     * See {@link Converter}<br/>
     * <p/>
     * <p/>
     * <p/>
     * The databinding validation/conversion phases are:<br/>
     * - validate after get <br/>
     * - convert <br/>
     * - validate after convert <br/>
     * - validate before set
     * <p/>
     * <p/>
     * <p/>
     * Ex:
     * <p/>
     * <p/>
     * <pre>
     * &#064;Bindable(model = MyModel.class)
     * public class MyView extends Composite {
     *
     * 	&#064;Bindings(@Binding(property = &quot;id&quot;, viewToModelValidator = @Validator(afterGet = IntegerTypeValidator.class)))
     * 	private Text idTextField;
     *
     * 	&#064;InjectResource(@To(clazz = IntegerTypeValidator.class, property = &quot;controlDecoration&quot;))
     * 	private ControlDecoration salesConfigIdControlDecoration;
     *
     * }
     *
     * public class MyModel {
     *
     * 	private Integer id;
     *
     * }
     * </pre>
     *
     * @param source - the source
     * @param target - the target
     */
    BindingResult bind(Object source, Object target);


    /**
     * Validates the errors. <br/>
     *
     * @return true if the validation errors are not fixed
     */

    boolean hasValidationErrors(BindingContext dataBindingContext);

}
